package netapp.tcp_2;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        // 创建服务器对象
        ServerSocket ss = new ServerSocket(6666);
        Socket accept = ss.accept();

        // 二、读取客户端发送的数据
        BufferedReader br = new BufferedReader(new InputStreamReader(accept.getInputStream()));
        String s = br.readLine();
        System.out.println(s);

        // 三、向客户端写出反馈数据
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("服务器反馈数据");
        bw.flush();

        // 关闭客户端
        accept.close();
        // 关闭服务端
        ss.close();
    }
}
